<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreateTask extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        /**
         * (
        `created_at` timestamp(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
        `updated_at` timestamp(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
        `deleted_at` timestamp(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
         */
        Schema::create('task', function (Blueprint $table) {
            $table->integerIncrements('id');
            $table->unsignedInteger('cooperative_id')->default(0)->comment('合作商id');
            $table->unsignedInteger('employer_id')->default(0)->comment('悬赏主id');
            $table->string('title', 64)->default('')->comment('任务标题');
            $table->string('cover_image', 255)->default('')->comment('任务主图');
            $table->string('product_name', 32)->default('')->comment('产品名称');
            $table->string('description', 255)->default('')->comment('任务要求');
            $table->string('tags', 400)->default('')->comment('标签');
            $table->unsignedInteger('audit_time')->default(0)->comment('审核时间：小时为单位');
            $table->unsignedDecimal('price', 10, 2)->default(0.00)->comment('单价');
            $table->unsignedInteger('end_time')->default(0)->comment('任务截至时间');
            $table->unsignedInteger('count')->default(0)->comment('任务总数');
            $table->unsignedInteger('done_count')->default(0)->comment('完成数');
            $table->unsignedInteger('remaining_count')->default(0)->comment('剩余可领取数');
            $table->unsignedTinyInteger('getter_user_info')->default(0)->comment('是否收集用户信息');
            $table->string('hint_message', 64)->default('')->comment('收集用户信息框提示信息');
            $table->unsignedInteger('user_finish_time')->default(0)->comment('用户完成最大时间');
            $table->unsignedInteger('estimated_time')->default(0)->comment('预估完成时间');
            $table->unsignedDecimal('total_price', 10, 2)->default(0.00)->comment('总价钱');
            $table->unsignedTinyInteger('finish_status')->default(0)->comment('完成状态：1未全部完成，2全部完成');
            $table->unsignedTinyInteger('show_status')->default(0)->comment('展示状态：1下架，2上架，3已截至，4已退款');
            $table->unsignedTinyInteger('audit_status')->default(0)->comment('审核状态：1待审核，2审核通过，3审核失败');
            $table->unsignedTinyInteger('disable_status')->default(0)->comment('是否禁用：1冻结，2正常');
            $table->unsignedDecimal('commission_percent', 10, 2)->default(0.00)->comment('佣金抽成比例');
            $table->string('contact', 20)->default('')->comment('联系方式');
            $table->unsignedTinyInteger('auto_payment')->default(0)->comment('自动打款：0否，1是');
            $table->timestamps();
            $table->softDeletes();
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('task');
    }
}
